import React, { useState } from "react";
function State() {
  // 本身函数组件的state状态的，16.8增加useState后他能代替state的相关功能
  const [state, setState] = useState({
    useName: "gqg",
    age: 30,
  });
  const addAge = () => {
    setState({
      ...state,
      age: state.age + 1,
    });
    console.log(state.useName)
  };
  return (
    <div>
      <h4>姓名：{state.useName}</h4>
      <h4>年龄：{state.age}</h4>
      <button onClick={addAge}>增加一岁</button>
    </div>
  );
}
export default State;
